package action.tempalate;

import action.tempalate.vo.Account;


public abstract class BaseAccount {
    protected Account account;

    public BaseAccount(Account account) {
        this.account = account;
    }

    private void display(){
        System.out.println("用户："+account.getUsername()+"的账户(含利息)为"+account.getAccount());
    }

    /**
     * 钩子函数，可以提供默认实现，这样子类未覆盖时就走默认的逻辑
     * @return
     */
    protected boolean verify(){
        return true;
    }

    abstract void CalculateInterest();

    /**
     * 模版方法，定义执行逻辑
     */
    protected void handle(){
        if (verify()){
            CalculateInterest();
            display();
        }else{
            System.out.println("请先输入正确的账号密码完成登录，再进行操作");
        }
    }
}
